home *** CD-ROM | disk | FTP | other *** search
/ Gold Medal Software 3 / Gold Medal Software - Volume 3 (Gold Medal) (1994).iso / prog / proxy14.arj / MERGE.PRX < prev    next >
Text File  |  1992-05-09  |  591b  |  20 lines

  1. eos="eos";
  2. ch1=channel();
  3. ch2=channel();
  4. ch3=channel();
  5. task merge(inp1,inp2,out;x) {
  6. n=0;
  7. while (true) {
  8.  if(n==2) {out!eos;skip;}
  9.  if(avail(inp1)) {inp1?x;if(x==eos) n=n+1;
  10.                          else out!x;}
  11.  if(avail(inp2)) {inp2?x;if(x==eos) n=n+1;
  12.                          else out!x;}
  13.              }};
  14. task source1(out) {out!1;out!3;out!eos;};
  15. task source2(out) {out!2;out!4;out!5;out!eos;};
  16. task sink(inp;x) {inp?x;while(x!=eos) {print x;inp?x;}};
  17. task main() {start source1(ch1); start source2(ch2);start merge(ch1,ch2,ch3);
  18.              start sink(ch3);};
  19. end
  20.